from django.contrib import admin
from .models import EmergencyInfo, EmergencyEvent

@admin.register(EmergencyInfo)
class EmergencyInfoAdmin(admin.ModelAdmin):
    list_display = ('family_member', 'blood_type', 'rh_factor', 'view_count', 'qr_scan_count', 'last_accessed_at')
    list_filter = ('blood_type', 'rh_factor', 'last_reviewed_date')
    search_fields = ('family_member__user__username', 'emergency_contact_name')
    readonly_fields = ('view_count', 'qr_scan_count', 'last_accessed_at')

@admin.register(EmergencyEvent)
class EmergencyEventAdmin(admin.ModelAdmin):
    list_display = ('user', 'family_member', 'event_type', 'success_status', 'follow_up_required', 'created_at')
    list_filter = ('event_type', 'success_status', 'follow_up_required', 'created_at')
    search_fields = ('user__username', 'family_member__user__username')
    readonly_fields = ('response_time',)